import { lazy } from "react";
import { withKeepAlive } from "keepalive-react-component";
import Home from "@/views/Home.jsx";

const Detail = lazy(() => import("@/views/Detail.jsx"));
const Store = lazy(() => import("@/views/Store.jsx"));
const Personal = lazy(() => import("@/views/Personal.jsx"));
const Update = lazy(() => import("@/views/Update.jsx"));
const Page404 = lazy(() => import("@/views/Page404.jsx"));
const Login = lazy(() => import("@/views/Login.jsx"));

const routes = [
  {
    path: "/",
    name: "home",
    component: withKeepAlive(Home, { cacheId: "Home", scroll: true }),
    meta: {
      title: "知乎日报-WebApp",
    },
  },
  {
    path: "/detail/:id",
    name: "detail",
    component: Detail,
    meta: {
      title: "新闻详情-知乎日报",
    },
  },
  {
    path: "/personal",
    name: "personal",
    component: Personal,
    meta: {
      title: "个人中心-知乎日报",
    },
  },
  {
    path: "/store",
    name: "store",
    component: Store,
    meta: {
      title: "我的收藏-知乎日报",
    },
  },
  {
    path: "/update",
    name: "update",
    component: Update,
    meta: {
      title: "个人信息修改-知乎日报",
    },
  },
  {
    path: "/login",
    name: "login",
    component: Login,
    meta: {
      title: "登录-知乎日报",
    },
  },
  {
    path: "/*",
    name: "404",
    component: Page404,
    meta: {
      title: "404-知乎日报",
    },
  },
];

export default routes;
